package cn.jetpiece.cloud.system.dp.app.modular.biz.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.jetpiece.cloud.system.dp.app.modular.biz.entity.DpTApp;
import cn.jetpiece.cloud.system.dp.app.modular.biz.entity.DpTScopeData;
import cn.jetpiece.cloud.system.dp.app.modular.biz.mapper.DpTAppMapper;
import cn.jetpiece.cloud.system.dp.app.modular.biz.service.IDpTAppService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * dp_t_app
 *
 * @author jetpiece
 * @since 2023-05-15
 */
@Service
public class DpTAppServiceImpl extends ServiceImpl<DpTAppMapper, DpTApp> implements IDpTAppService {

    @Override
    public DpTApp getByAppKey(String appKey) {
        if (StringUtils.isBlank(appKey)) {
            return null;
        }
        LambdaQueryWrapper<DpTApp> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(DpTApp::getAppKey, appKey);
        List<DpTApp> appList = this.list(queryWrapper);
        if (CollUtil.isNotEmpty(appList)) {
            return appList.get(0);
        }
        return null;
    }
}
